

#include "stdafx.h"
#include "CharacterSet.h"
#include <windows.h>

void CharacterSet::ConvertUTF8ToASCII(const char *src, std::string dst)
{
	int len = MultiByteToWideChar( CP_UTF8, 0, src, -1, NULL, 0 );
	wchar_t* pWideChar = new wchar_t[len];
	MultiByteToWideChar( CP_UTF8, 0, src, -1, pWideChar, len );

	len = WideCharToMultiByte( CP_ACP, 0, pWideChar, -1, NULL, 0, NULL, NULL );
	char* pASCII = new char[len];
	WideCharToMultiByte( CP_ACP, 0, pWideChar, -1, pASCII, len, NULL, NULL );

	dst = pASCII;

	delete pASCII;
	delete pWideChar;
}